<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改文章</title>
    <#include "/views/rec.html">
    <link href="<@full_path path='css/editormd.css' />" rel="stylesheet">
    <script type="text/javascript" src="<@full_path path='js/editormd.js' />"></script>
</head>
<body>
<div class="ui container">
    <form class="ui form" style="margin-top: 15px;" id="article-form">
    	<input type="hidden" name="id" value="${article.id!}">
        <div class="field">
        	<label>文章标题</label>
            <input type="text" name="title" style="width: 100%;" value="${article.title!}">
        </div>
        <div class="fields">
			<div class="four wide field">
				<label>文章类别&nbsp;&nbsp;<span
					style="color: blue; cursor: pointer;" id="add-category">新增</span></label>
				<div class="ui search selection dropdown" id="selection-category" style="z-index: 20;">
					<input type="hidden" name="categoryId"> <i
						class="dropdown icon"></i>
					<div class="default text"></div>
					<div class="menu">
						<#if categoryList?? && categoryList?size gt 0>
							<#list categoryList as item>
								<div class="item <#if item.id == article.categoryId>selected</#if>" data-value="${item.id!}">${item.name!}</div>
							</#list>
						</#if>
					</div>
				</div>
			</div>
			<div class="twelve wide field">
            	<label>文章标签</label>
                <div class="ui fluid multiple search selection dropdown" id="selection-tag" style="z-index: 20;">
                    <input type="hidden" name="tags">
                    <i class="dropdown icon"></i>
                    <div class="default text">文章标签</div>
                    <div class="menu">
                    	<#if article?? && article.tags??>
                    		<#list article.tags?split(",") as item>
                    			<div class="item" data-value="${item!}">${item!}</div>
                    		</#list>
                    	</#if>
                    </div>
                </div>
            </div>
        </div>
        <div id="test-editormd">
            <textarea class="editormd-markdown-textarea" name="content">${article.content!}</textarea>
            <textarea class="editormd-html-textarea" name="htmlContent"></textarea>
        </div>
		<div class="field">
		    <label>文章概述</label>
		    <textarea rows="4" style="width: 100%;" name="summary">${article.summary!}</textarea>
		</div>
		<div class="ui error  message" id="article-message"></div>
		<div>
			<input type="button" class="ui green basic button right floated"
				style="margin-bottom: 35px;" value="更新" onclick="updateArticle();"> <input
				type="button" class="ui orange basic button right floated"
				style="margin-bottom: 35px;" value="取消">
		</div>
	</form>
</div>

<!-- modal start  -->
<div class="ui small modal">
	 <i class="close icon"></i>
	<div class="header">新增文章类别</div>
	<div class="content">
		<form class="ui equal width form" id="categoryForm">
			<div class="field">
				<label>分类名称</label> <input type="text" name="name"
					style="width: 100%;">
			</div>
			<div class="field">
				<label>分类说明</label> <input type="text" name="content"
					style="width: 100%;">
			</div>
			<div class="fields">
				<div class="field">
					<label>索引位置</label> <input type="text" name="orderIndex" value="50" style="width: 100%;">
				</div>
				<!--  
				<div class="field">
					<label>设为默认</label>
					<select class="ui search dropdown" name="isDefault">
					    <option value="0">不用了</option>
						<option value="1">好的</option>
					</select>
				</div>
				-->
				<div class="field">
					<label>是否公开</label>
					<select class="ui search dropdown" name="isPublic">
						<option value="1" <#if article?? && article.isPublic?? && article.isPublic == '1'>selected='selected'</#if>>是的</option>
						<option value="0" <#if article?? && article.isPublic?? && article.isPublic == '0'>selected='selected'</#if>>不可以</option>
					</select>
				</div>
			</div>
			<div class="ui error  message" id="category-message"></div>
		</form>
	</div>
	<div class="actions">
		<div class="ui primary button">确定</div>
		<div class="ui negative button">取消</div>
	</div>
</div>
<!-- modal end -->

<div class="ui inverted page dimmer">
	<div class="ui text loader">文章更新中...</div>
</div>

<script type="text/javascript">
	var full_path = "<@full_path path='' />";
	var user_name = "${LOGIN_USER.userName!}";
	var categoryId = "${article.categoryId!}";
	var tags = "${article.tags!}"
	var tagArray = tags.split(",");
</script>
<script type="text/javascript" src="<@full_path path='js/article/edit.js' />"></script>
</body>
</html>